
<form class="layui-form" action="" lay-filter="svrPv">
	<div class="layuimini-main">
		<div class="layui-form layuimini-form">
			<div class="layui-form-item">
				<label class="layui-form-label required">用户名称</label>
				<div class="layui-input-block">
					<input type="text" name="userName" lay-verify="required"
						lay-reqtext="不能为空,长度小于50个字" maxLength='50'
						placeholder="请输入真实姓名" value="" class="layui-input">
					<input type="hidden" name="type" value="1" />
					<input type="hidden" name="id" />
					<!--  -->
					<input type="hidden" name="status" value="1" />
					<input type="hidden" name="ispId" value="12" />
					<input type="hidden" name="svrId" value="12" />
					<input type="hidden" name="createTime" />
					<!--  -->
					<!--  <tip>请填写服务商名称。需要服务商</tip> -->
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label required">性别</label>
				<div class="layui-input-block">
					<select id="sex" name="sex" lay-filter="st">
						<option value="男">男</option>
						<option value="女">女</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label required">手机</label>
				<div class="layui-input-block">
					<input type="phone" name="tel" maxLength='20'
						value="" class="layui-input" disabled="disabled">
						<tip>手机号是登录名,不能修改</tip>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label ">电子邮箱</label>
				<div class="layui-input-block">
					<input type="email" name="email" maxLength='50'
						placeholder="长度小于50个字" lay-verify="email" lay-reqtext="邮件格式不正确"
						value="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-normal" lay-submit
						lay-filter="saveBtn">确认保存</button>
				</div>
			</div>
		</div>
	</div>
</form>

<script>
    layui.use(['form', 'table','layarea','common'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            layarea = layui.layarea,
            //data = layui.data,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        
        //layer.alert(JSON.stringify(window.data));
        

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        
        $.ajax({
			url: "/user/getOwn",
			type: 'get',
			async: false,
			dataType: 'json',
			success: function(data) {
				window.svrInitData= data
				console.log(data);
			}
		});
        
        //表单初始赋值,
        form.val("svrPv", window.svrInitData)
 		form.render();  

		layarea.render({
		        elem: '#area-picker',
		        	data:window.svrInitData,
		        /*data: {
		            province: '广东省',
		             city: '深圳市',
		             county: '龙岗区',
		       	},*/
		        change: function (res) {
		            //选择结果
		            //console.log(res);
		        }
		    });
		    
 		     
         //监听提交
        form.on('submit(saveBtn)', function (data) {
        	$.ajax({
				url: "/user",
				type: 'post',
				async: false,
				data : JSON.stringify(data.field),//要转换为字符格式
				dataType: 'json',
				contentType:"application/json",
				success: function(data) {
					window.svrInitData= data.obj;
					//console.log(data.obj);
				}
			});
            return false;
        });
     //初始化选择框    
	layui.common.initSelect();
    });
</script>